package com.linsen.sample.controller;

import cn.dev33.satoken.stp.SaLoginConfig;
import cn.dev33.satoken.stp.SaLoginModel;
import cn.dev33.satoken.stp.StpUtil;
import cn.licoy.encryptbody.annotation.decrypt.DecryptBody;
import cn.licoy.encryptbody.annotation.encrypt.EncryptBody;
import cn.licoy.encryptbody.enums.EncryptBodyMethod;
import com.linsen.core.common.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * @author zhaoyong
 * @date 2023/7/19
 */
@RestController
@RequestMapping("/index")
@Api(tags = "index")
public class IndexController {

    @ApiOperation("get")
    @PostMapping("/get")
    @EncryptBody(value = EncryptBodyMethod.AES)
    @DecryptBody
    public Result get(@RequestBody Result request) {
        System.out.println(request);
        StpUtil.login(1001, SaLoginConfig.create().setToken("231321321"));
        return Result.data(StpUtil.getTokenValue());
    }
}
